package com.bing.bingPro.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bing.bingPro.controller.dto.TFiveOrderTypeDto;
import com.bing.bingPro.controller.vo.TDetachOrderVo;
import com.bing.bingPro.controller.vo.TMoveOrderVo;
import com.bing.bingPro.entity.TDetachOrder;
import com.bing.bingPro.mapper.TDetachOrderMapper;
import com.bing.bingPro.service.TDetachOrderService;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author qilong
 * @description 针对表【t_detach_order】的数据库操作Service实现
 * @createDate
 */
@Service
public class TDetachOrderServiceImpl extends ServiceImpl<TDetachOrderMapper, TDetachOrder>
        implements TDetachOrderService {

    @Override
    public List<TDetachOrderVo> detachList(TFiveOrderTypeDto tOrderYearDto) {
        Date date = Date.valueOf(tOrderYearDto.getTime());
        return baseMapper.selectList(Wrappers.lambdaQuery(TDetachOrder.class)
                        .eq(true, TDetachOrder::getDt, date))
                .stream()
                .map(tDetachOrder -> {
                    TDetachOrderVo vo = new TDetachOrderVo();
                    BeanUtil.copyProperties(tDetachOrder, vo);
                    return vo;
                })
                .collect(Collectors.toList());
    }

    @Override
    public List<TDetachOrderVo> exportDetach(TFiveOrderTypeDto tOrderYearDto) {
        List<TDetachOrderVo> tDetachOrderVos = this.detachList(tOrderYearDto);
        return tDetachOrderVos.stream()
                .map(tDetachOrderVo -> {
                    TDetachOrderVo vo = new TDetachOrderVo();
                    BeanUtil.copyProperties(tDetachOrderVo, vo);
                    return vo;
                })
                .collect(Collectors.toList());
    }
}




